package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
	"hello/database"
)

// @title           Swagger Example API
// @version         1.0
// @description     This is a sample server celler server.

// @contact.name   API Support
// @contact.url    http://www.swagger.io/support
// @contact.email  support@swagger.io

// @BasePath  /api/v1
func main() {
	engine := gin.Default()
	// 注册swagger静态文件路由
	engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

	// 初始化数据库连接
	database.InitDB()

	initRoutes(engine)

	// 启动服务器并添加错误处理
	if err := engine.Run(":88"); err != nil {
		fmt.Printf("启动服务器时发生错误: %v\n", err)
	}
}
